<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

$base_dir = 'App\frontend\controllers';

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

//根目录
Route::group(['prefix' => '', 'namespace' => $base_dir , 'middleware' => []], function () {
    //获取用户手机号
    Route::post('/getUserPhone', 'LogonController@getUserPhone');
    //登录
    Route::post('/logon', 'LogonController@codeGetInfo');
});

//首页
Route::group(['prefix' => '', 'namespace' => $base_dir . '\homepage', 'middleware' => []], function () {
    //首页
    Route::group(['prefix' => 'homepage'],function (){
        //首页-头部
        Route::get('/top', 'HomePageController@homePageTop');
        //爆款推荐
        Route::get('/hot_goods', 'HomePageController@hotGoods');
        //搜索商品
        Route::get('/search_goods', 'HomePageController@searchGoods');
        //热门搜索记录
        Route::get('/hot_search', 'HomePageController@hotSearch');
        //搜索历史记录
        Route::get('/search_history', 'HomePageController@searchHistory');
        //确认订单
//        Route::get('/hot_goods', 'HomePageController@hotGoods');
    });

    //搜索
    Route::group(['prefix' => 'search'],function (){
        //热搜数据
        Route::get('/hot_search', 'SearchController@hotSearchData');
        //搜索
        Route::get('/search', 'SearchController@searchData');
    });
});

//位置
Route::group(['prefix' => '', 'namespace' => $base_dir . '\location' , 'middleware' => []], function () {
    //位置
    Route::group(['prefix' => 'local'],function (){
        //附近取货地点列表
        Route::get('/nearby_pickup', 'LocationController@nearbyPickupLists');
        //取货点城市选择接口
        Route::get('/select_city', 'LocationController@selectCity');
        //推荐城市
        Route::get('/recommend_city', 'LocationController@recommendedCity');
        //我的取货点
        Route::get('/my_pickup', 'LocationController@myPickup');
        //选择取货点
        Route::get('/select_local', 'LocationController@selectLocation');
    });
});

//购物车
Route::group(['prefix' => '', 'namespace' => $base_dir . '\shopcart', 'middleware' => []], function () {
    //购物车
    Route::group(['prefix' => 'cart'],function (){
        //加入购物车
        Route::post('/add_cart', 'ShopCartController@addCart');
        //购物车列表
        Route::get('/lists', 'ShopCartController@cartLists');
        //购物车优惠
        Route::get('/cart_pre', 'ShopCartController@cartPreference');
    });
});

//商品模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\goods', 'middleware' => []], function () {
    //商品
    Route::group(['prefix' => 'goods'],function (){
        //test
        Route::any('/test', ["uses" => 'GoodsController@test']);
        //商品列表
        Route::any('/list', ["uses" => 'GoodsController@getGoodsList']);
        //商品详情
        Route::any('/details', ["uses" => 'GoodsController@getGoodsDetails']);
        //商品分类
        Route::get('/cate_list', 'CategoryController@getCategoryList');
        Route::get('/cate_lists', 'CategoryController@getLists');

        //商品评论
        Route::any('/comment_list', ["uses" => 'CommentController@getCommentList']);
    });



});

// 订单模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\orders', 'middleware' => []], function () {
    //订单
    Route::group(['prefix' => 'orders'],function (){
        //订单列表
        Route::any('/list', 'OrderController@getOrdersList');
        //创建订单详情
        Route::get('/create', 'OrderController@createOrders');
        //支付成功
        Route::get('/pay', 'OrderController@payOrders');
    });
});

// 活动模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\activity', 'middleware' => []], function () {
    //礼盒抽奖
    Route::group(['prefix' => 'gift'],function (){
        //礼盒抽奖列表
        Route::get('/list', 'GifBoxLotteryControllers@getGifBoxLotteryList');
        //礼盒抽奖详情
        Route::get('/detail', 'GifBoxLotteryControllers@getGifBoxLotteryDetails');
        //抽奖活动详情
        Route::get('/draw_info', 'DrawActivityControllers@getDrawActivityDetails');
        //抽奖
        Route::get('/result', 'DrawActivityControllers@getWiningResult');
        //抽奖记录
        Route::get('/record', 'DrawActivityControllers@getDrawRecord');
    });
});


//优惠券模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\coupon' , 'middleware' => []], function () {
    //优惠券
    Route::group(['prefix' => 'coupon'],function (){
        //领券中心-优惠券列表
        Route::any('/list', 'CouponController@lists');
        //领券中心-优惠券详情
        Route::any('/detail', 'CouponController@detail');
    });
});


//积分模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\points' , 'middleware' => []], function () {
    //积分
    Route::group(['prefix' => 'points'],function (){
        //积分首页
        Route::get('/points_home', 'PointsController@pointsHomePage');
        //积分兑换商品列表
        Route::get('/points_goods_list', 'PointsController@pointsGoodsLists');
    });
});

//地区模块
Route::group(['prefix' => '', 'namespace' => $base_dir , 'middleware' => []], function () {
    Route::group(['prefix' => 'area'],function (){
        //获取区域列表数据
        Route::any('/list', ["uses" => 'AreaController@areaAll']);
        //获取省级数据列表
        Route::any('/pro_list', ["uses" => 'AreaController@provinceList']);
        //根据上级id获取数据列表
        Route::any('/sea_list', ["uses" => 'AreaController@searchList']);
    });
});

//会员模块
Route::group(['prefix' => '', 'namespace' => $base_dir . '\member', 'middleware' => []], function () {
    //会员
    Route::group(['prefix' => 'member'],function (){
        //会员首页
        Route::any('/index', ["uses" => 'MemberController@memberData']);
        //会员详情
        Route::any('/info', ["uses" => 'MemberController@memberInfo']);
        //修改昵称
        Route::any('/modify_name', ["uses" => 'MemberController@modifyNickName']);
        //收货地址
        Route::group(['prefix' => 'address'],function (){
            //收货地址列表
            Route::any('/list', ["uses" => 'MemberAddressController@getAddressList']);
            //修改收货地址
            Route::any('/edit', ["uses" => 'MemberAddressController@editAddress']);
            //增加收货地址
            Route::any('/add', ["uses" => 'MemberAddressController@addAddress']);
            //删除收货地址
            Route::any('/delete', ["uses" => 'MemberAddressController@deleteAddress']);
            //设置默认地址
            Route::any('/set-default', ["uses" => 'MemberAddressController@setDefault']);
        });
        //密码
        Route::group(['prefix' => 'pass'],function (){
            //修改登录密码
            Route::any('/edit_login', ["uses" => 'MemberController@editLoginPass']);
            //设置支付密码
            Route::any('/set_pay', ["uses" => 'MemberController@setPayPass']);
            //修改支付密码
            Route::any('/edit_pay', ["uses" => 'MemberController@editPayPass']);
        });
        //取钱包余额
        Route::any('/wallet_balance', ["uses" => 'MemberController@getWalletBalance']);
        //余额明细
        Route::any('/balance_details', ["uses" => 'MemberController@getBalanceDetails']);
        //充值
        Route::any('/recharge', ["uses" => 'MemberController@recharge']);
        //佣金明细
        Route::any('/commission_details', ["uses" => 'MemberController@getCommissionDetails']);
        //提现佣金
        Route::any('/withdrawal_commission', ["uses" => 'MemberController@withdrawalCommission']);
        //积分明细
        Route::any('/points_details', ["uses" => 'MemberController@getPointsDetails']);
        //我的服务列表
        Route::any('/my_service_list', ["uses" => 'MemberController@getMyServiceList']);
        //我的服务详情
        Route::any('/my_service_details', ["uses" => 'MemberController@getMyServiceDetails']);
        //核销订单
        Route::any('/verif_orders', ["uses" => 'MemberController@verifOrders']);
        //我的卡券
        Route::any('/my_card_coupon', ["uses" => 'MemberController@getMyCardCoupon']);

    });

});



//Route::group(['namespace' => 'App\frontend\modules\goods\controllers'], function () {
//    Route::get('goodsCategory', 'CategoryController@getCategory');
//});

//Route::get('/hello', function () {
//    return 'world';
//});
